<?php include template('toper','common');?>
<?php include template('header','common');?>
		<!--面包屑-->
		<div class="container crumbs clearfix">
			<p class="fl layout">
			<i class="icon-crumbs"></i>
				{catpos($_GET['id'])}
			</p>
		</div>
		<!--list-->
		<div class="item-two-column container clearfix">
			<div class="left fl">
				<div class="list-category border border-gray-white">
					<div class="item-title">{$category['top_parentid']['name']}</div>
					<div class="layout sp-category">
						{hd:goods tagfile="category" order="sort asc" catid="$category[top_parentid][id]" method="lists"}
						{loop $data $r}
						{if $_GET[id] == $r[id] || $r[id] == $category[parent_id] || $id == $category[top_parentid][id]}
						<dl class="open">
							<dt><i></i>{$r[name]}</dt>
							{hd:goods tagfile="category" order="sort asc" catid="$r[id]" method="lists"}
							{loop $data $rr}
							<dd><a href="<?php echo !empty($rr['url']) ? $rr['url'] : url('goods/index/lists',array('id'=>$rr['id']))?>">{$rr['name']}</a></dd>
							{/loop}
							{/hd}
						</dl>
						{else}
						<dl>
							<dt><i></i>{$r[name]}</dt>
							{hd:goods tagfile="category" order="sort asc" catid="$r[id]" method="lists"}
							{loop $data $rr}
							<dd><a href="<?php echo !empty($rr['url']) ? $rr['url'] : url('goods/index/lists',array('id'=>$rr['id']))?>">{$rr['name']}</a></dd>
							{/loop}
							{/hd}
						</dl>
						{/if}
						{/loop}
						{/hd}
					</div>
				</div>
				<div class="layout margin-top border border-gray-white clearfix">
					<div class="item-title">看了又看</div>
					<div class="ext-content padding clearfix">
						<div class="ext-show">
							<div class="ext-con-wrap clearfix">
								{hd:goods tagfile="goods" method="lists" num="6" order="rand()"}
								{loop $data $r}
								<div class="ext-con-box">
										<a href="{url('goods/index/detail',array('sku_id'=>$r['sku_id']))}" title="{$r['sku_name']}"><img src="<?php echo thumb($r['thumb'])?>" width="90" height="90" /></a>
										<p>￥<?php echo $r['prom_price']?></p>
								</div>
								{/loop}
								{/hd}
							</div>
						</div>
					</div>
				</div>
				<!--列表页广告-->
				{hd:ads tagfile="ads" method="lists" position="2" num="1" order="rand()"}
					{if ($data['list'])}
						<div class="margin-top ad fl">
								{loop $data['list'] $r}
									{if empty($r['content'])}
										<a href="javascript:;" >
											<img src="{$data['defaultpic']}" />
										</a>
									{else}
										<a href="{url('ads/index/adv_view',array('id'=>$r['id'],'url'=>$r['link']))}" title="{$r['title']}">
											<img src="{$r['content']}"/>
										</a>
									{/if}
								{/loop}
						</div>
					{/if}
				{/hd}
			</div>
			<div class="fr right goods-list-wrap">
				<!--热销商品-->
				{hd:goods tagfile="goods" method="lists" catid="$category[id]" num="4" statusext="4"}
				{if count($data) > 0}
				<div class="margin-bottom border border-gray-white item-blue-top">
					<div class="item-title padding-left">推荐商品</div>
					<div class="padding selling-goods">
						<ul>
							{loop $data $r}
							<li>
								<a href="{url('goods/index/detail',array('sku_id'=>$r['sku_id']))}" class="pic"><img src="<?php echo thumb($r['thumb'])?>" /></a>
								<div class="info">
									<a class="title" href="{url('goods/index/detail',array('sku_id'=>$r['sku_id']))}" title="{$r['sku_name']}">{$r['sku_name']}</a>
									<p>销售价：<span class="txt-mix">￥<?php echo $r['prom_price']?></span></p>
									<a class="cart-btn" href="">立即抢购</a>
								</div>
							</li>
							{/loop}
						</ul>
					</div>
				</div>
				{/if}
				{/hd}
				<!--属性选择-->
				<div class="border border-gray-white item-blue-top selected-type">
					<div class="item-title padding-left"><span class="text-sub">{$category['name']}</span>-商品筛选<a class="fr margin-big-right text-sub" href="{url('lists',array('id'=>$_GET[id]))}">重置筛选</a></div>
					<div class="list-type-selected clearfix">
					{if !empty($brands)}
						<dl class="item-type hidden">
							<dt>品牌：</dt>
							<dd class="type-name">
							{if $_GET['brand_id']}
								<a class="hidden" href="{create_url('brand_id', 0)}">全部</a>
							{else}
								<a class="hidden selected" href="javascript:void(0)">全部</a>
							{/if}
							<?php foreach ($brands AS $brand):?>
								{if $_GET['brand_id']==$brand['id']}
								<a class="hidden selected" href="javascript:void(0)">{$brand['name']}</a>
								{else}
								<a class="hidden" href="{create_url('brand_id', $brand['id'])}">{$brand['name']}</a>
								{/if}
							<?php endforeach?>
							</dd>
							<dd class="more"></dd>
						</dl>
					{/if}
						{if $grades}
						<dl class="item-type hidden">
							<dt>价格：</dt>
							<dd class="type-name">
							{if $_GET['price']}
								<a class="hidden" href="{create_url('price', '')}">全部</a>
							{else}
								<a class="hidden selected" href="javascript:void(0)">全部</a>
							{/if}
							<?php
								$current = current($grades);
								$end = end($grades);
							?>
							{if $current[0] > 1}
								<?php $max_price = $current[0] - 1;?>
								{if $_GET['price'] == '0,'.$max_price}
								<a class="hidden selected" href="javascript:void(0)">{$max_price}以下</a>
								{else}
								<a class="hidden" href="{create_url('price', '0,'.$max_price)}">{$max_price}以下</a>
								{/if}
							{/if}
							<?php foreach ($grades AS $grade):?>
								{if $_GET['price'] == implode(',',$grade)}
								<a class="hidden selected" href="javascript:void(0)"><?php echo $grade[0].'-'.$grade[1];?></a>
								{else}
								<a class="hidden" href="{create_url('price', implode(',',$grade))}"><?php echo $grade[0].'-'.$grade[1];?></a>
								{/if}
							<?php endforeach?>
							<?php $min_price = $end[1] + 1;?>
								{if $_GET['price'] == $min_price.',0'}
									<a class="hidden selected" href="javascript:void(0)">{$min_price}以上</a>
								{else}
									<a class="hidden" href="{create_url('price', $min_price.',0')}">{$min_price}以上</a>
								{/if}
							</dd>
							<dd class="more"></dd>
						</dl>
						{/if}
						{hd:goods method="lists" tagfile="type" catid='$_GET[id]'}
						<?php $attrs = array_keys($data);?>
						{loop $data $k $r}
						{if $r[search] == 1}
						<dl class="item-type hidden">
							<dt>{$r['name']}：</dt>
							<dd class="type-name">
							{if $_GET['attr'][$k]}
								<a class="hidden" href="{create_url($k, '', $attrs)}">全部</a>
							{else}
								<a class="hidden selected" href="javascript:void(0)">全部</a>
							{/if}
							{loop $r['value'] $v}
							{if $_GET['attr'][$k] != $v}
								<a class="hidden" href="{create_url($k, $v, $attrs)}">{$v}</a>
							{else}
								<a class="hidden selected" data-status="true" href="javascript:void(0)">{$v}</a>
							{/if}
							{/loop}
							</dd>
							<dd class="more"></dd>
						</dl>
						{/if}
						{/loop}
						{/hd}
						{hd:goods method="specs" tagfile="type" catid='$_GET[id]'}
						<?php $spec= array_keys($data);?>
						{loop $data $k $r}
						<dl class="item-type hidden">
							<dt>{$r['name']}：</dt>
							<dd class="type-name">
							{if $_GET['attr'][$k]}
								<a class="hidden" href="{create_url($k, '', $spec)}">全部</a>
							{else}
								<a class="hidden selected" href="javascript:void(0)">全部</a>
							{/if}
							{loop $r['value'] $v}
							{if $_GET['attr'][$k] != $v}
								<a class="hidden" href="{create_url($k, $v, $spec)}">{$v}</a>
							{else}
								<a class="hidden selected" data-status="true" href="javascript:void(0)">{$v}</a>
							{/if}
							{/loop}
							</dd>
							<dd class="more"></dd>
						</dl>
						{/loop}
						{/hd}
					</div>
				</div>
				<!--筛选-->
				<div class="margin-top border border-gray-white item-blue-top filter">
					<dl>
						<dt>排序方式：</dt>
						<dd {if $result['sort'] == 'comper'} class="selected" {/if}><a href="{create_url('sort','comper,')}">综合{if $result['sort'] == 'comper'}<i class="ico-down"></i>{/if}</a></dd>
						<dd {if $result['sort'] == 'sale'} class="selected" {/if}><a href="{create_url('sort','sale,')}">销量{if $result['sort'] == 'sale'}<i class="ico-down"></i>{/if}</a></dd>
						<dd {if $result['sort'] == 'shop_price'} class="selected" {/if}><a href="{create_url('sort','shop_price,'.$result['_by'])}">价格{if $result['sort'] == 'shop_price'}{if $result['_by'] == 'asc'}<i class="ico-down"></i>{else}<i class="ico-up"></i>{/if}{/if}</a></dd>
						<dd {if $result['sort'] == 'hits'} class="selected" {/if}><a href="{create_url('sort','hits,')}">人气{if $result['sort'] == 'hits'}<i class="ico-down"></i>{/if}</a></dd>
						<dd class="filter-page item-page border-none">
							{hd:goods tagfile="goods" method="page" catid="$_GET[id]" brand_id="$result[brand_id]" order="$result[order]" goods_ids="$result[_goods_ids]" num="12" price="$result[price]" page="$_GET[page]"}
							{$data['page']}
							{/hd}
						</dd>
					</dl>
				</div>
				<!--商品列表-->
				<div class="list-wrap">
					<ul class="list-h clearfix">
					{hd:goods tagfile="goods" method="lists" catid="$_GET[id]" brand_id="$result[brand_id]" order="$result[order]" goods_ids="$result[_goods_ids]" num="12" price="$result[price]" page="$_GET[page]"}
					{loop $data $r}
					<li>
						<div class="lh-wrap">
							<div class="p-img">
								<a href="{url('goods/index/detail',array('sku_id'=>$r['sku_id']))}"><img src="<?php echo thumb($r['thumb'],230,230)?>" width="230" height="230" /></a>
								{if $r['status_ext'] == 1}
								<div class="picon pi3"></div>
								{elseif $r['status_ext'] == 2}
								<div class="picon pi2"></div>
								{elseif $r['status_ext'] == 3}
								<div class="picon pi1"></div>
								{/if}
							</div>
							<div class="p-name">
								<a href="{url('goods/index/detail',array('sku_id'=>$r['sku_id']))}">{if isset($r['prom_time']) && $r['prom_time'] > 0}<span class="padding-small-left padding-small-right radius-small bg-mix text-white margin-small-right">限时促销</span>{/if}{$r['sku_name']}</a>
							</div>
							<div class="p-price">
								<span class="text-mix">￥<?php echo $r['prom_price']?></span>
							</div>
							<div class="p-hand text-right">
								<div class="short-share">
									{if $r[number] > 0}
									<a class="cart-btn fl" data-event="cart_add" data-skuids="{$r['sku_id']}">加入购物车</a>
									{else}
									<span class="fl">商品已售罄</span>
									{/if}
									{if is_favorite($this->member['id'],$r['sku_id'])}
									<span class="button"><em class="text-gray">已收藏</em></span>
									{else}
									<a class="button collect-btn" data-skuid="{$r['sku_id']}" data-url="{urlencode($_SERVER['REQUEST_URI'])}" data-price="{$r['shop_price']}">收藏商品</a>
									{/if}
								</div>
							</div>
						</div>
					</li>
					{/loop}
					{/hd}	
					</ul>
				</div>
				<div class="paging margin-top padding-tb clearfix">
					<?php echo $pages?>
				</div>
			</div>
		</div>
		<?php include template('toolbar','common');?>
		<?php include template('footer','common');?>
		<script>
			$(function(){
				
				loadAfterAction();
				
				//展示和隐藏更多属性
				$(".item-type .more a").live('click',function(){
					var _child = $(this).parent().prev(".type-name").children();
					if(!$(this).hasClass("fold")){
						$(this).html("收起").addClass("fold");
						_child.removeClass("hidden");
					}else{
						$(this).html("更多").removeClass("fold");
						_child.addClass("hidden").slice(0,11).removeClass("hidden");
					}
					return false;
				});


				
				//展示和隐藏更多属性选项
				$(".more-type").live('click',function(){
					if(!$(this).hasClass("fold")){
						$(this).html("收起选项").addClass("fold");
						$(".selected-type .item-type").removeClass("hidden");
					}else{
						$(this).html("更多选项").removeClass("fold");
						$(".selected-type .item-type").addClass("hidden").slice(0,5).removeClass("hidden");
					}
					return false;
				});
				
				$(".list-h li").hover(function(){
					$(this).addClass("hover");
				},function(){
					$(this).removeClass("hover");
				});
				
				//筛选条
				filterBar();
				
			})
			
			//添加属性选择的更多
			function loadAfterAction(){
				var flog = true;
				$(".item-type").each(function(){
					if($(this).find("a[data-status]").length>0&&$(this).index()>4){
						flog = false;
					}
					$(this).children(".type-name").find("a").slice(0,11).removeClass("hidden");
					if($(this).children(".type-name").find("a").length>10){
						$(this).children(".more").append('<a class="text-sub" href="">更多</a>');
					}
				});
				if($(".item-type").length>5&&flog){
					$(".item-type").slice(0,5).removeClass("hidden");
					$(".selected-type").after('<a class="more-type" href="">更多选项</a>');
				}else{
					$(".item-type").removeClass("hidden");
				}
			}
			
			//筛选条
			function filterBar(){
				$(window).scroll(function(){
					var doctop = $(document).scrollTop();
					var _head = $(".list-wrap").offset().top-41;
					if(doctop <= _head){
						$('.goods-list-wrap').removeClass('filter-bar');
					}
					if(doctop > _head){
						$('.goods-list-wrap').addClass('filter-bar');
					}
				});
			}
		</script>
	</body>
</html>
